package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zlict.admin.domain.RdFixedAssets;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.ProjectDeviceWorkingHours;
import com.zlict.admin.service.IProjectDeviceWorkingHoursService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 项目设备工时Controller
 * 
 * @author lqh
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/admin/deviceHours")
@RequiredArgsConstructor
public class ProjectDeviceWorkingHoursController extends BaseController
{
    private final IProjectDeviceWorkingHoursService projectDeviceWorkingHoursService;

    /**
     * 查询项目设备工时列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:deviceHours:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectDeviceWorkingHours projectDeviceWorkingHours)
    {
        startPage();
        List<ProjectDeviceWorkingHours> list = projectDeviceWorkingHoursService.selectProjectDeviceWorkingHoursList(projectDeviceWorkingHours);
        return getDataTable(list);
    }

    /**
     * 导出项目设备工时列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:deviceHours:export')")
    @Log(title = "项目设备工时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectDeviceWorkingHours projectDeviceWorkingHours)
    {
        List<ProjectDeviceWorkingHours> list = projectDeviceWorkingHoursService.selectProjectDeviceWorkingHoursList(projectDeviceWorkingHours);
        ExcelUtil<ProjectDeviceWorkingHours> util = new ExcelUtil<ProjectDeviceWorkingHours>(ProjectDeviceWorkingHours.class);
        util.exportExcel(response, list, "项目设备工时数据");
    }

    /**
     * 获取项目设备工时详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:deviceHours:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(projectDeviceWorkingHoursService.selectProjectDeviceWorkingHoursById(id));
    }

    /**
     * 新增项目设备工时
     */
//    @PreAuthorize("@ss.hasPermi('admin:deviceHours:add')")
    @Log(title = "项目设备工时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectDeviceWorkingHours projectDeviceWorkingHours)
    {
        return toAjax(projectDeviceWorkingHoursService.insertProjectDeviceWorkingHours(projectDeviceWorkingHours));
    }

    /**
     * 修改项目设备工时
     */
//    @PreAuthorize("@ss.hasPermi('admin:deviceHours:edit')")
    @Log(title = "项目设备工时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectDeviceWorkingHours projectDeviceWorkingHours)
    {
        return toAjax(projectDeviceWorkingHoursService.updateProjectDeviceWorkingHours(projectDeviceWorkingHours));
    }

    /**
     * 删除项目设备工时
     */
//    @PreAuthorize("@ss.hasPermi('admin:deviceHours:remove')")
    @Log(title = "项目设备工时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(projectDeviceWorkingHoursService.deleteProjectDeviceWorkingHoursByIds(ids));
    }


    /**
     * 查询设备工时列表（不分页）
     */
//    @PreAuthorize("@ss.hasPermi('admin:fixedAssets:getList')")
    @GetMapping("/getList")
    public AjaxResult getList(ProjectDeviceWorkingHours projectDeviceWorkingHours)
    {
        List<ProjectDeviceWorkingHours> list = projectDeviceWorkingHoursService.selectProjectDeviceWorkingHoursList(projectDeviceWorkingHours);
        return success(list);
    }
}
